package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.ysd.entity.tuiJianCP;
import com.ysd.util.DBManger;

public class tuiJianCPDaoImpl {
	public List<tuiJianCP> gettuiJianCPList(){
		List<tuiJianCP> tuichanpinList = new ArrayList<tuiJianCP>();
		Connection conn=DBManger.getConnection();
		Statement st=null;
		ResultSet rs = null;
		
		try {
			st = conn.createStatement();
			rs=st.executeQuery("Select * From tuijianchanpinbiao_copy order By Rand() Limit 6");
			while(rs.next()) {
				int tuijianId=rs.getInt("tuiJianChanPinId");
				String tuijiantu=rs.getString("tuiJianTu");
				int waiJianId = rs.getInt("tuiJianWaiJianId");
				tuiJianCP tjt=new tuiJianCP(tuijianId,tuijiantu,waiJianId);
				tuichanpinList.add(tjt);
			}
			return tuichanpinList;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}finally {
			DBManger.closeAll(conn, st, rs);
			
		}
		
		
		
	}
}
